package com.hmall.search.mvc;

import com.hmall.search.utils.ThreadLocal;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description SearchMvc
 * @Author 刘
 * @Date 2024-11-16
 */
@Component
public class HandlerMvc implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("拦截处理:" + request.getRequestURI());
        String token = request.getHeader("Authorization");
        ThreadLocal.setUserId(token);
        return true;
    }
}
